package com.tencent.wxpay.demo.common;

import com.tencent.wxpay.demo.model.AccessToken;
import com.tencent.wxpay.demo.util.WeixinUtil;
import com.tencent.wxpay.demo.model.JSTicket;

/**
 * 常量类
 */
public class Constants {
    public static final String APPID = "";
    public static final String APPSECRET = "";
    // 网页授权获取用户基本信息
    // 页面授权的回调页面
    public static final String REDIRECT_URI = WeixinUtil.urlEncodeUTF8("http://www.xxx.com/wxpay/index.html");
    // 1.页面授权的url  scope=snsapi_base
    public static final String OAUTH_CODE_BASE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid="
            + APPID
            + "&redirect_uri=" + REDIRECT_URI
            + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";

    // 2.换取网页授权access_token页面的构造方式,其中 CODE需要替换
    public static final String OAUTH_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid="
            + APPID
            + "&secret="
            + APPSECRET
            + "&code=CODE&grant_type=authorization_code";

    // 接口调用的accessToken
    public static AccessToken accessToken;
    // jsapi调用的jsTicket
    public static JSTicket jsTicket;

    public static void main(String[] args) {
        System.out.println(OAUTH_CODE_BASE_URL);
    }
}
